package com.wmlive.hhvideo.jpush;

import android.text.TextUtils;

import com.wmlive.hhvideo.common.base.BasePresenter;
import com.wmlive.hhvideo.common.network.HttpConstant;
import com.wmlive.hhvideo.heihei.beans.login.MobileLoginResponse;
import com.wmlive.hhvideo.heihei.beans.personal.UserHomeResponse;
import com.wmlive.hhvideo.heihei.beans.splash.InitCatchData;
import com.wmlive.hhvideo.heihei.login.AccountUtil;
import com.wmlive.hhvideo.heihei.personal.view.IPersonalView;
import com.wmlive.networklib.entity.BaseResponse;
import com.wmlive.networklib.entity.DCNetObserver;

/**
 * Created by XueFei on 2017/7/13.
 * <p>
 * 极光绑定用户
 */

public class JpushBindUserPresenter extends BasePresenter<IJpushBindUserView> {
    public JpushBindUserPresenter(IJpushBindUserView view) {
        super(view);
    }

    /**
     * 极光绑定用户
     *
     * @param device_uuid
     * @param apns_token
     */
    public void bindUser(String device_uuid, String apns_token) {
        String url = InitCatchData.sysDevicePushInfo();
        if (!TextUtils.isEmpty(url)) {
            executeRequest(HttpConstant.TYPE_JPUSH_BIND_USER, getHttpApi().bindUser(url, device_uuid, apns_token, 0))
                    .subscribe(new DCNetObserver<BaseResponse>() {
                        @Override
                        public void onRequestDataReady(int requestCode, String message, BaseResponse response) {
                            if (null != viewCallback) {
                                viewCallback.handleBindSucceed();
                            }
                        }

                        @Override
                        public void onRequestDataError(int requestCode, int serverCode, String message) {

                        }
                    });
        }
    }
}
